/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AgregarEstadio.java
 *
 * Created on 19-may-2010, 20:44:38
 */

package Interfaces;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import wcb.BD;
import wcb.Estadio;

/**
 *
 * @author Angiita
 */
public class AgregarEstadio extends javax.swing.JFrame {
BD bd = new BD();
    /** Creates new form AgregarEstadio */
    public AgregarEstadio() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        jAtras = new javax.swing.JButton();
        jAgregar = new javax.swing.JButton();
        LNombre = new javax.swing.JLabel();
        LEstadio = new javax.swing.JLabel();
        LCiudad = new javax.swing.JLabel();
        LAforo = new javax.swing.JLabel();
        LFecha = new javax.swing.JLabel();
        lFechaC = new javax.swing.JLabel();
        jNombre = new javax.swing.JTextField();
        jCiudad = new javax.swing.JTextField();
        jAforo = new javax.swing.JTextField();
        jFechaC = new com.toedter.calendar.JDateChooser();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jAtras.setText("Atras");
        jAtras.setPreferredSize(new java.awt.Dimension(73, 23));
        jAtras.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jAtrasActionPerformed(evt);
            }
        });
        jAtras.setBounds(70, 330, 100, 23);
        jLayeredPane1.add(jAtras, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jAgregar.setText("Agregar");
        jAgregar.setMaximumSize(new java.awt.Dimension(59, 23));
        jAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jAgregarActionPerformed(evt);
            }
        });
        jAgregar.setBounds(310, 330, 100, 23);
        jLayeredPane1.add(jAgregar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        LNombre.setForeground(new java.awt.Color(255, 255, 0));
        LNombre.setText("Nombre:");
        LNombre.setBounds(60, 100, 70, 14);
        jLayeredPane1.add(LNombre, javax.swing.JLayeredPane.DEFAULT_LAYER);

        LEstadio.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        LEstadio.setForeground(new java.awt.Color(255, 255, 0));
        LEstadio.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LEstadio.setText("Estadio");
        LEstadio.setBounds(190, 20, 130, 22);
        jLayeredPane1.add(LEstadio, javax.swing.JLayeredPane.DEFAULT_LAYER);

        LCiudad.setForeground(new java.awt.Color(255, 255, 0));
        LCiudad.setText("Ciudad:");
        LCiudad.setBounds(60, 140, 50, 14);
        jLayeredPane1.add(LCiudad, javax.swing.JLayeredPane.DEFAULT_LAYER);

        LAforo.setForeground(new java.awt.Color(255, 255, 0));
        LAforo.setText("Aforo:");
        LAforo.setBounds(60, 180, 50, 14);
        jLayeredPane1.add(LAforo, javax.swing.JLayeredPane.DEFAULT_LAYER);

        LFecha.setForeground(new java.awt.Color(255, 255, 0));
        LFecha.setText("Fecha de");
        LFecha.setBounds(60, 210, 50, 20);
        jLayeredPane1.add(LFecha, javax.swing.JLayeredPane.DEFAULT_LAYER);

        lFechaC.setForeground(new java.awt.Color(255, 255, 0));
        lFechaC.setText("Construccion:");
        lFechaC.setBounds(60, 230, 80, 14);
        jLayeredPane1.add(lFechaC, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jNombre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jNombreActionPerformed(evt);
            }
        });
        jNombre.setBounds(180, 100, 180, 20);
        jLayeredPane1.add(jNombre, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jCiudad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCiudadActionPerformed(evt);
            }
        });
        jCiudad.setBounds(180, 140, 180, 20);
        jLayeredPane1.add(jCiudad, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jAforo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jAforoActionPerformed(evt);
            }
        });
        jAforo.setBounds(180, 180, 180, 20);
        jLayeredPane1.add(jAforo, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jFechaC.setBounds(180, 220, 180, 20);
        jLayeredPane1.add(jFechaC, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/estadio.png"))); // NOI18N
        jLabel1.setText("jLabel1");
        jLabel1.setBounds(0, 0, 500, 400);
        jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jAtrasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAtrasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jAtrasActionPerformed

    private void jAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAgregarActionPerformed
        // TODO add your handling code here:
//        String aforo, nombre, ciudad;
//        Integer c;
//        aforo= jAforo.getText().toString();
//        nombre= jNombre.getText().toString();
//        ciudad= jCiudad.getText().toString();
//        c= Integer.parseInt(aforo);
//
//        Calendar cal1 = jFechaC.getCalendar();
//        int dia1 = cal1.get(Calendar.DATE);
//        int mes1 = cal1.get(Calendar.MONTH);
//        int año1 = cal1.get(Calendar.YEAR)- 1900;
//        java.sql.Date Date1=new java.sql.Date(año1,mes1,dia1); //Date Sistema
//
//        if((jAforo.getText().equals("")) || (nombre.equals("")) || (ciudad.equals("")) || (aforo.equals("")))
//    {
//        JOptionPane.showMessageDialog(null,"ERROR, Debe llenar todos los campos");
//    }
//    else
//    {
//        Estadio nuevo_estadio = new Estadio(null,nombre,ciudad,c,Date1);
////        Calendar cal = Calendar.getInstance();
////        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
////        String now = sdf.format(cal.getTime());
//
//                int x = 0;
//            try {
//                x = bd.insertarEstadio(nuevo_estadio);
//            } catch (SQLException ex) {
//                Logger.getLogger(AgregarEstadio.class.getName()).log(Level.SEVERE, null, ex);
//            }
//                if (x==1)
//                    JOptionPane.showMessageDialog(null,"Error, el Estadio ya existe");
//                else
//                    JOptionPane.showMessageDialog(null,"Estadio agregado Exitosamente");
//
//    }

    }//GEN-LAST:event_jAgregarActionPerformed

    private void jCiudadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCiudadActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCiudadActionPerformed

    private void jAforoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAforoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jAforoActionPerformed

    private void jNombreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNombreActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jNombreActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new AgregarEstadio().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel LAforo;
    private javax.swing.JLabel LCiudad;
    private javax.swing.JLabel LEstadio;
    private javax.swing.JLabel LFecha;
    private javax.swing.JLabel LNombre;
    private javax.swing.JTextField jAforo;
    private javax.swing.JButton jAgregar;
    private javax.swing.JButton jAtras;
    private javax.swing.JTextField jCiudad;
    private com.toedter.calendar.JDateChooser jFechaC;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JTextField jNombre;
    private javax.swing.JLabel lFechaC;
    // End of variables declaration//GEN-END:variables

}
